/**   
* @Title: YwShouLiController.java 
* @Package com.zjdiepu.www.manage.api.zpp.controller 
* 
* @author zhangpp
* @date 2017年5月31日 上午11:02:43 
* @version V1.0   
*/
package com.zjdiepu.www.manage.api.zpp.controller;
import io.swagger.annotations.Api;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import springfox.documentation.annotations.ApiIgnore;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.annotation.Add;
import com.zjdiepu.www.base.core.AbstractSysUser;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.core.PageVo;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.base.enums.type.OperateType;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.common.util.ZhppDateUtil;
import com.zjdiepu.www.ibiz.base.IDpBaseDataDictionaryService;
import com.zjdiepu.www.ibiz.base.IDpBaseDealerInfoService;
import com.zjdiepu.www.ibiz.base.IDpBaseDealerInfoSubService;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.other.IOtherAuditInfoService;
import com.zjdiepu.www.ibiz.other.IOtherFundChannelConfigService;
import com.zjdiepu.www.ibiz.system.IBaseBusiUnitService;
import com.zjdiepu.www.ibiz.system.IBaseRemitAccountService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessExtrasService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessLoanService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessService;
import com.zjdiepu.www.ibiz.yw.IYwFeesService;
import com.zjdiepu.www.ibiz.yw.IYwFeesSubService;
import com.zjdiepu.www.ibiz.yw.IYwLoanAbandonService;
import com.zjdiepu.www.ibiz.yw.IYwTransferService;
import com.zjdiepu.www.ibiz.zpp.PublicService;
import com.zjdiepu.www.ibiz.zpp.YwShouLiService;
import com.zjdiepu.www.model.base.dto.DpBaseDataDictionary;
import com.zjdiepu.www.model.base.dto.DpBaseDealerInfo;
import com.zjdiepu.www.model.base.dto.DpBaseDealerInfoSub;
import com.zjdiepu.www.model.base.ext.DpBaseDataDictionaryExt;
import com.zjdiepu.www.model.other.dto.OtherFundChannelConfig;
import com.zjdiepu.www.model.system.dto.BaseBusiUnit;
import com.zjdiepu.www.model.system.dto.BaseRemitAccount;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.model.yw.dto.YwBusinessCar;
import com.zjdiepu.www.model.yw.dto.YwBusinessExtras;
import com.zjdiepu.www.model.yw.dto.YwBusinessLoan;
import com.zjdiepu.www.model.yw.dto.YwFees;
import com.zjdiepu.www.model.yw.dto.YwLoanAbandon;
import com.zjdiepu.www.model.yw.dto.YwTransfer;
import com.zjdiepu.www.model.zpp.pub.ext.ParamsExt;
import com.zjdiepu.www.model.zpp.pub.ext.WhereSqlExt;
import com.zjdiepu.www.model.zpp.ywsl.dto.DaKuanKeHuTable;
import com.zjdiepu.www.model.zpp.ywsl.ext.DaKuanKeHuTableExe;
import com.zjdiepu.www.model.zpp.ywsl.ext.RefundInformationExt;
import com.zjdiepu.www.util.CommonUtil;

/**      
 * 项目名称：diepu-parent-manage   
 * 类名称：YwShouLiController   
 * 类描述：   
 * 创建人：zhangpp
 * 创建时间：2017年5月31日 上午11:02:43   
 * 修改人：zhangpp
 * 修改时间：2017年5月31日 上午11:02:43   
 * 修改备注：   
 * @version V1.0     
 */
@RestController
@RequestMapping(value= "YwShouLiController", produces="application/json;charset=UTF-8")
@Api(tags = {"作者：张鹏鹏，电话：15158822934"}, produces="application/json;charset=UTF-8")
public class YwShouLiController extends BaseController
{
	
	@Resource
	private ICachedDictionaryService iCachedDictionaryService; 
	
	@Resource
	private YwShouLiService YwShouLiService;
	
	@Resource
	private IYwLoanAbandonService iYwLoanAbandonService;
	
	@Resource
	private IBaseRemitAccountService iBaseRemitAccountService;
	
	@Resource
	private IYwFeesService iYwFeesService;
	
	@Resource
	private IYwBusinessService iYwBusinessService;
	
	@Resource
	private IBaseBusiUnitService baseBusiUnitService;
	
	@Resource
	private IDpBaseDataDictionaryService iDpBaseDataDictionaryService;
	
	@Resource
	private IYwFeesSubService iYwFeesSubService;
	
	@Resource
	private PublicService publicService;
	
	@Resource
	private IYwTransferService iYwTransferService;
	
	@Resource
	private IOtherAuditInfoService iOtherAuditInfoService;
	
	@Resource
	private IOtherFundChannelConfigService otherFundChannelConfigService;
	
	@Resource
	private IDpBaseDealerInfoService iDpBaseDealerInfoService;
	
	@Resource
	private IDpBaseDealerInfoSubService iDpBaseDealerInfoSubService;
	
	@Resource
	private IYwBusinessExtrasService ywBusinessExtrasService;
	
	@Resource
	private IYwBusinessLoanService ywBusinessLoanService;
	
	/**
	*   新增模块：打款客户表 
	*  @author  zhangpp
	*  @Title:  getDaKuanKeHuTableList  
	*    
	*  @param  @param daKuanKeHuTableExe
	*  @param  @return
	*  @param  @throws Exception        设定文件  
	*  @return  Map<String,Object>        返回类型  
	*  @version  V1.0
	*  @throws
	 */
    @RequestMapping(value = "getDaKuanKeHuTableList", method = RequestMethod.POST)
    public Map<String, Object> getDaKuanKeHuTableList(DaKuanKeHuTableExe daKuanKeHuTableExe) throws Exception
    {
		Map<String, Object> maps = success();
		String sqlXmls = " and (t.added_status1 = 300 or t.added_status1 = 500) ";
		if(null != daKuanKeHuTableExe)
		{
			if(StringUtils.isNotBlank(daKuanKeHuTableExe.getSubmitTimeStart()) && StringUtils.isNotBlank(daKuanKeHuTableExe.getSubmitTimeEnd()))
			{
				int start = ZhppDateUtil.dateConvertTimeStamp(daKuanKeHuTableExe.getSubmitTimeStart(), "yyyy-MM-dd");
				int end =  ZhppDateUtil.dateConvertTimeStamp(daKuanKeHuTableExe.getSubmitTimeEnd(), "yyyy-MM-dd");
				
				sqlXmls += " and t.created >= "+start;
				sqlXmls += " and t.created < "+(end + 86400);
			}
			else if(StringUtils.isNotBlank(daKuanKeHuTableExe.getSubmitTimeStart()))
			{
				int start = ZhppDateUtil.dateConvertTimeStamp(daKuanKeHuTableExe.getSubmitTimeStart(), "yyyy-MM-dd");
				sqlXmls += " and t.created >= "+start;
			}
			else if(StringUtils.isNotBlank(daKuanKeHuTableExe.getSubmitTimeEnd()))
			{
				int end =  ZhppDateUtil.dateConvertTimeStamp(daKuanKeHuTableExe.getSubmitTimeEnd(), "yyyy-MM-dd");
				sqlXmls += " and t.created < "+(end + 86400);
			}
			
			if(StringUtils.isNotBlank(daKuanKeHuTableExe.getCustomerName()))
			{
				sqlXmls += " and t.customer_name like CONCAT('%', '"+daKuanKeHuTableExe.getCustomerName()+"', '%') ";
			}
			
			if(StringUtils.isNotBlank(daKuanKeHuTableExe.getCustomerNo()))
			{
				sqlXmls += " and t.customer_no like CONCAT('%', '"+daKuanKeHuTableExe.getCustomerNo()+"', '%') ";
			}
			
			if(StringUtils.isNotBlank(daKuanKeHuTableExe.getSalesmanName()))
			{
				sqlXmls += " and saler.`name` like CONCAT('%', '"+daKuanKeHuTableExe.getSalesmanName()+"', '%') ";
			}
		}
		daKuanKeHuTableExe.setWhereSql(sqlXmls);
		daKuanKeHuTableExe.notDeleted();
        PageVo page = getPage(daKuanKeHuTableExe);
        int records = YwShouLiService.countDaKuanKeHuTable(daKuanKeHuTableExe);
        page.setRecords(records);
        if (records > 0) 
        {
        	List<DaKuanKeHuTable> list = YwShouLiService.getDaKuanKeHuTableList(daKuanKeHuTableExe);
        	for(int i=0;i<list.size();i++)
        	{
        		DaKuanKeHuTable daKuanKeHuTable = list.get(i);
        		daKuanKeHuTable.setChannelType(iCachedDictionaryService.getName(daKuanKeHuTable.getChannelType(), DataDicType.CHANNEL_TYPE));
        		daKuanKeHuTable.setDealerLevel(iCachedDictionaryService.getName(daKuanKeHuTable.getDealerLevel(), DataDicType.DEALER_LEVEL));
        		daKuanKeHuTable.setBankLoan(iCachedDictionaryService.getName(daKuanKeHuTable.getBankLoan(), DataDicType.LOAN_BANK));
        		
        		if(daKuanKeHuTable.getAddedStatus1().equals("300"))
        		{
        			daKuanKeHuTable.setAddedStatus1("已打款");
        		}
        		else if(daKuanKeHuTable.getAddedStatus1().equals("500"))
        		{
        			daKuanKeHuTable.setAddedStatus1("垫款调整A已完成");
        		}
        	}
            page.setRows(list);
        }
        else 
        {
            page.setRows(CollectionInitUtil.emptyList());
        }
        maps.put("result", page);
		return maps;
    }
	
	/**
	*  经销商 修改
	*  @author  zhangpp
	*  @Title:  diepuDealer  
	*    
	*  @param  @param dpBaseDealerInfo
	*  @param  @param dpBaseDealerInfoSub
	*  @param  @return        设定文件  
	*  @return  ApiResponse        返回类型  
	*  @version  V1.0
	*  @throws
	 */
	@RequestMapping(value="diepuDealerUpdate",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public ApiResponse diepuDealerUpdate(DpBaseDealerInfo dpBaseDealerInfo,DpBaseDealerInfoSub dpBaseDealerInfoSub)
	{
		AbstractSysUser currentUser = getCurrentUser();
		YwShouLiService.diepuDealerUpdate(currentUser, dpBaseDealerInfo, dpBaseDealerInfoSub);
        return ApiResponse.success(true);
	}
	
	/**
	*  经销商更新  查询
	*  @author  zhangpp
	*  @Title:  getDealer  
	*    
	*  @param  @param dpBaseDealerInfo
	*  @param  @param dpBaseDealerInfoSub
	*  @param  @return        设定文件  
	*  @return  ApiResponse        返回类型  
	*  @version  V1.0
	*  @throws
	 */
	@RequestMapping(value="getDealer",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> getDealer(String dealerId)
	{
		Map<String, Object> maps = success();
		DpBaseDealerInfo dealerInfo = iDpBaseDealerInfoService.selectById(dealerId);
		String unitId = dealerInfo.getUnitId();
		BaseBusiUnit baseBusiUnit = baseBusiUnitService.selectById(unitId);
		if(null != baseBusiUnit) {
			dealerInfo.setUnitName(baseBusiUnit.getOrgName());
		}
		maps.put("dealerInfo", dealerInfo);
		DpBaseDealerInfoSub dpBaseDealerInfoSub = YwShouLiService.getDealerSub(dealerId);
		maps.put("dpBaseDealerInfoSub", dpBaseDealerInfoSub);
		return maps;
	}
	
	
	/**
	*  添加经销商
	*  @author  zhangpp
	*  @Title:  diepuDealer  
	*    
	*  @param  @param otherFundChannelConfig
	*  @param  @return        设定文件  
	*  @return  ApiResponse        返回类型  
	*  @version  V1.0
	*  @throws
	 */
	@RequestMapping(value="diepuDealer",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public ApiResponse diepuDealer(DpBaseDealerInfo dpBaseDealerInfo,DpBaseDealerInfoSub dpBaseDealerInfoSub)
	{
		AbstractSysUser currentUser = getCurrentUser();
		YwShouLiService.diepuDealer(currentUser, dpBaseDealerInfo, dpBaseDealerInfoSub);
        return ApiResponse.success(true);
	}
	
	/**
	*  添加
	*  @author  zhangpp
	*  @Title:  qudaoAdd  
	*    
	*  @param  @param otherFundChannelConfig
	*  @param  @return        设定文件  
	*  @return  ApiResponse        返回类型  
	*  @version  V1.0
	*  @throws
	 */
	@RequestMapping(value="qudaoAdd",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public ApiResponse qudaoAdd(@Validated(Add.class) @ModelAttribute OtherFundChannelConfig otherFundChannelConfig)
	{
		AbstractSysUser currentUser = getCurrentUser();
    	otherFundChannelConfig.setModifier(currentUser.getId()); //统一使用修改人和修改人名称来初始化
    	otherFundChannelConfig.setModifierName(currentUser.getName());
    	if(null == otherFundChannelConfig || otherFundChannelConfig.getId().equals(""))
    	{
    		 otherFundChannelConfigService.saveUpdateAndDelete(otherFundChannelConfig, OperateType.add);
    	}
    	else
    	{
    		 otherFundChannelConfigService.saveUpdateAndDelete(otherFundChannelConfig, OperateType.edit);
    	}
        return ApiResponse.success(true);
	}
	
	
	/**
	*  
	*  @author  zhangpp
	*  @Title:  getZiJinQuDao  
	*    
	*  @param  @return        设定文件  
	*  @return  Map<String,Object>        返回类型  
	*  @version  V1.0
	*  @throws
	 */
	@RequestMapping(value="getZiJinQuDao",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> getZiJinQuDao()
	{
		Map<String, Object> maps = success();
		Map<String, String> FUND_CHANNEL = iCachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.FUND_CHANNEL,"请选择...");
		maps.put("FUND_CHANNEL", FUND_CHANNEL);
		
		String sqlXmls = "select t.id,t.org_name,t.org_code from base_busi_unit t where t.parent_id = '1' and t.dp_status = 1";
		List<Map<String, String>> resultMaps = publicService.queryWhereSql(sqlXmls);
		maps.put("resultMaps", resultMaps);
		return maps;
	}
	
	/**
	* 业务受理  查询过户登记资料信息 
	* @author zhangpp
	* @Title: getYwTransfer 
	* 
	* @param @param ywTransfer
	* @param @return    设定文件 
	* @return Map<String,Object>    返回类型 
	* @version V1.0
	* @throws
	 */
	@RequestMapping(value="getYwTransfer",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> getYwTransfer(String busiId,String statusTransfer)
	{
		Map<String, Object> maps = success();
		
		//过户资料
		YwTransfer ywTransfer = new YwTransfer();
		ywTransfer.setBusiId(busiId);
		ywTransfer.setDpStatus(1);
		ywTransfer = iYwTransferService.selectRefined(ywTransfer);
		maps.put("ywTransfer", ywTransfer);
		
		//审核退回资料
		if(StringUtils.isNotBlank(statusTransfer))
		{
			if(statusTransfer.equals("20"))
			{
				String sqlXmls = "select t.id,t.audit_detail,t.audit_postil from other_audit_info t where t.mode_id = 'M_ghsh' and t.audit_status = '4' and t.audit_name = '过户审核' and t.dp_status = 1 and t.busi_id = '"+busiId+"' order by t.created desc limit 1";
				List<Map<String, String>> reMaps = publicService.queryWhereSql(sqlXmls);
				maps.put("reMaps", reMaps);
			}
		}
		return maps;
	}
	
	/**
	* 业务受理  弃贷表
	* @author zhangpp
	* @Title: ywShouLiQiDaiBiao 
	* 
	* @param @param ywLoanAbandon
	* @param @param ywBusiness
	* @param @return
	* @param @throws Exception    设定文件 
	* @return ApiResponse    返回类型 
	* @version V1.0
	* @throws
	 */
	@RequestMapping(value="ywShouLiQiDaiBiao",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public ApiResponse ywShouLiQiDaiBiao(@ApiIgnore YwLoanAbandon ywLoanAbandon,YwBusiness ywBusiness) throws Exception
	{
		AbstractSysUser currentUser = getCurrentUser();
		YwShouLiService.saveYwShouLiQingDaiBiao(ywLoanAbandon, ywBusiness, currentUser);
        return ApiResponse.success(true);
	}
	
	/**
	* 业务受理  弃贷表
	* @author zhangpp
	* @Title: getQiDaiYuanYin 
	* 
	* @param @param refundInformationExt
	* @param @return    设定文件 
	* @return Map<String,Object>    返回类型 
	* @version V1.0
	* @throws
	 */
	@RequestMapping(value="getQiDaiYuanYin",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> getQiDaiYuanYin(@ApiIgnore RefundInformationExt refundInformationExt,YwLoanAbandon ywLoanAbandon)
	{
		Map<String, Object> maps = success();
		Map<String, String> result = iCachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.KEHU_QIDAI_YUANYIN,"请选择...");
		maps.put("result", result);
		
		//查询弃贷的数据
		ywLoanAbandon = iYwLoanAbandonService.selectRefined(ywLoanAbandon);
		maps.put("ywLoanAbandon", ywLoanAbandon);
        return maps;
	}
	
	/**
	* 业务受理 客户过户登记
	* @author zhangpp
	* @Title: saveKeHuDengJiService 
	* 
	* @param @param paramsExt
	* @param @return    设定文件 
	* @return Map<String,Object>    返回类型 
	* @version V1.0
	* @throws
	 */
	@RequestMapping(value="saveKeHuDengJiService",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> saveKeHuDengJiService(@ApiIgnore ParamsExt paramsExt,YwBusinessCar ywBusinessCar)
	{
		Map<String, Object> maps = success();
		AbstractSysUser currentUser = getCurrentUser();
		YwShouLiService.saveKeHuDengJiService(paramsExt, currentUser,ywBusinessCar);
		return maps;
	}
	
	/**
	 * 二手车过户调整
	 * 1、过户状态整个一个新的值 ： 已保存  （值为1）
	 * 2、增加一个保存按钮。点击保存的时候，将页面信息保存到   yw_transfer（需要增加车辆信息字段） 过户状态（status_transfer）为 已保存。不修改 yw_business_car  表
	 * 3、加载过户详情页面时，如果 yw_transfer 已经存在信息，就从  yw_transfer 加载，否则从 yw_business_car 加载；
	 * 4、‘保存提交’按钮修改为 ‘提交’，点击时先做保存动作，再做提交动作。
	 * 5、列表增加一列：状态。取 过户状态 （文本显示），放在第一列
	 * @param ywTransfer
	 * @param ywBusinessCar
	 * @return
	 */
	@RequestMapping(value="diepuCarTransfer",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> diepuCarTransfer(YwTransfer ywTransfer, YwBusinessCar ywBusinessCar,String executeType)
	{
		Map<String, Object> maps = success();
		AbstractSysUser currentUser = getCurrentUser();
		YwShouLiService.diepuCarTransfer(currentUser, ywTransfer, ywBusinessCar,executeType);
		return maps;
	}
	
	
	/**
	* 业务受理    按揭日报表 
	* @author zhangpp
	* @Title: getAnJieDayBiao 
	* 
	* @param @param paramsExt
	* @param @return    设定文件 
	* @return Map<String,Object>    返回类型 
	* @version V1.0
	* @throws
	 */
	@RequestMapping(value="getAnJieDayBiao",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> getAnJieDayBiao(ParamsExt paramsExt,String unitCode) 
	{
		Map<String, Object> maps = success();
		
		//结算方式
		Map<String, String> SettlementType_result = iCachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.SETTLEMENT_TYPE,"请选择...");
		maps.put("SettlementType_result", SettlementType_result);
		
		//返利方式
		Map<String, String> rebate_type = iCachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.REBATE_TYPE,"请选择...");
		maps.put("rebate_type", rebate_type);
		
		//如果是风控经理总监查看则执行
		YwFees ywFees = new YwFees();
		ywFees.setBusiId(paramsExt.getBusiId());
		ywFees = iYwFeesService.selectRefined(ywFees);
		maps.put("ywFees", ywFees);
		
		WhereSqlExt whereSqlExt = new WhereSqlExt();
		String whereSql = "select t.id,t.item_code,t.amount_item from yw_fees_sub t where t.busi_id = '"+paramsExt.getBusiId()+"' and t.dp_status = 1 order by t.item_code asc ";
		whereSqlExt.setWhereSql(whereSql);
		List<Map<String, String>> ywFeesSub = publicService.selectWhereSql(whereSqlExt);
		maps.put("ywFeesSub", ywFeesSub);
		
		//取征信押金
		YwBusinessExtras ywBusinessExtras = new YwBusinessExtras();
		ywBusinessExtras.setBusiId(paramsExt.getBusiId());
		ywBusinessExtras.setCodeExtras("AddGeposit");
		ywBusinessExtras.setDpStatus(1);
		ywBusinessExtras = ywBusinessExtrasService.selectRefined(ywBusinessExtras);
		maps.put("ywBusinessExtras", ywBusinessExtras);
		
		//签约贷款额  获取
		YwBusiness business = iYwBusinessService.selectById(paramsExt.getBusiId());
		maps.put("business", business);
		
		//取数据字典信息
		DpBaseDataDictionaryExt dpBaseDataDictionaryExt = new DpBaseDataDictionaryExt();
		dpBaseDataDictionaryExt.setBaseWhere();
	    dpBaseDataDictionaryExt.withOutPage();
	    dpBaseDataDictionaryExt.setParentValue(DataDicType.FUND_ITEM.getCode());
	    dpBaseDataDictionaryExt.setAddedValue1("01"); //启用的明细
	    dpBaseDataDictionaryExt.setOrderSql("`VALUE`");
		List<DpBaseDataDictionary> dictionary = iDpBaseDataDictionaryService.selectByExt(dpBaseDataDictionaryExt);
		maps.put("dictionary", dictionary);
		
		//按揭服务费
		YwBusinessLoan ywBusinessLoan = new YwBusinessLoan();
		ywBusinessLoan.setBusiId(paramsExt.getBusiId());
		ywBusinessLoan.setDpStatus(1);
		ywBusinessLoan = ywBusinessLoanService.selectRefined(ywBusinessLoan);
		maps.put("ywBusinessLoan", ywBusinessLoan);
		
		//打款名单维护查询
		if(null != unitCode && !("").equals(unitCode))
		{
			BaseRemitAccount baseRemitAccount = new BaseRemitAccount();
			baseRemitAccount.setOrgCode(unitCode);
			baseRemitAccount.setFundChannel("zy");
			baseRemitAccount.setDpStatus(1);
			BaseRemitAccount remit = iBaseRemitAccountService.selectRefined(baseRemitAccount);
			if(null != remit && !("").equals(remit))
			{
				remit.setBankId(iCachedDictionaryService.getName(remit.getBankId(), DataDicType.BANK));
				maps.put("remit", remit);
				return maps;
			}
			
			for(int i=0;i<5;i++)
			{
				if(unitCode.length() > 4)
				{
					unitCode = unitCode.substring(0, unitCode.length()-3);
					baseRemitAccount.setOrgCode(unitCode);
					baseRemitAccount.setFundChannel("zy");
					remit = iBaseRemitAccountService.selectRefined(baseRemitAccount);
					if(null != remit && !("").equals(remit))
					{
						remit.setBankId(iCachedDictionaryService.getName(remit.getBankId(), DataDicType.BANK));
						maps.put("remit", remit);
						return maps;
					}
				}
				
				if(unitCode.length() == 4)
				{
					baseRemitAccount.setOrgCode(unitCode);
					baseRemitAccount.setFundChannel("zy");
					remit = iBaseRemitAccountService.selectRefined(baseRemitAccount);
					if(null != remit && !("").equals(remit))
					{
						remit.setBankId(iCachedDictionaryService.getName(remit.getBankId(), DataDicType.BANK));
						maps.put("remit", remit);
						return maps;
					}
				}
			}
		}
		return maps;
	}
	
	/**
	* 业务受理  安街日报表
	* @author zhangpp
	* @Title: ywShouLiAnJieDayBiaoBiao 
	* 
	* @param @param ywFees
	* @param @param ywBusiness
	* @param @return
	* @param @throws Exception    设定文件 
	* @return ApiResponse    返回类型 
	* @version V1.0
	* @throws
	 */
	@RequestMapping(value="ywShouLiAnJieDayBiaoBiao",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public ApiResponse ywShouLiAnJieDayBiaoBiao(@ApiIgnore YwFees ywFees,YwBusiness ywBusiness,String key,String value) throws Exception
	{
		AbstractSysUser currentUser = getCurrentUser();
		YwShouLiService.diepuYwShouLiAnJieDayBiaoBiao(ywFees, ywBusiness, currentUser,key,value);
        return ApiResponse.success(true);
	}
	
	
	
	/**
	*  银行批量信息的下载
	*  @author  zhangpp
	*  @Title:  getBankAllXlsx  
	*    
	*  @param  @return        设定文件  
	*  @return  Map<String,Object>        返回类型  
	*  @version  V1.0
	*  @throws
	 */
    @RequestMapping(value="getBankAllXlsx",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> getBankAllXlsx() 
	{
		Map<String, Object> maps = success();
		String [] fileName = CommonUtil.getFileName("D://www//project//dpqc//file");
		if(null != fileName && fileName.length > 0)
		{
			Map<String, Object> fileMaps = CollectionInitUtil.emptyMap();
			for(String name:fileName)
	        {
				fileMaps.put(name, name);
	        }
			maps.put("fileMaps", fileMaps);
			maps.put("fileMapsCount", fileName.length);
		}
		return maps;
	}
}
